import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 全局组件navbar
import NavBar from 'components/common/nav/NavBar.vue'
// 全局组件backTop
import BackTop from 'components/common/backtop/BackTop.vue'
//引入mitt 全局事件总线
import mitt from 'mitt'

// 自定义插件(使用Vant)
import vantPlugin from '@/plugin/vantPlugin'
const app = createApp(App)

// import useVant from '@/plugin/useVant'
// 使用Vant
// useVant(app)
app
  .component('nav-bar', NavBar)
  .component('back-top', BackTop)
  .use(store)
  .use(router)
  .use(vantPlugin)
  .mount('#app')

// 判断是否登录
if (store.state.login.isLogin) {
  store.dispatch('cart/updateCart')
}

// 绑定全局事件总线
app.config.globalProperties.$bus = new mitt()
